from fastapi import HTTPException, status

class APIError(HTTPException):
    def __init__(self, code: int, message: str):
        super().__init__(
            status_code=status.HTTP_400_BAD_REQUEST,
            detail={"code": code, "data": message}
        )

class UnknownError(APIError):
    def __init__(self, message: str = "未知错误"):
        super().__init__(20000, message)

class NoPermissionError(APIError):
    def __init__(self, message: str = "无权限"):
        super().__init__(30000, message)

class UserBannedError(APIError):
    def __init__(self, message: str = "用户被禁止登录"):
        super().__init__(30001, message)

class InvalidCredentialsError(APIError):
    def __init__(self, message: str = "用户名或密码不正确"):
        super().__init__(30003, message)

class UserExistsError(APIError):
    def __init__(self, message: str = "用户名已存在"):
        super().__init__(30006, message)

class UserNotFoundError(APIError):
    def __init__(self, message: str = "用户不存在"):
        super().__init__(30010, message)

class DataNotFoundError(APIError):
    def __init__(self, message: str = "请求数据不存在"):
        super().__init__(40001, message)

class DuplicatePublishError(APIError):
    def __init__(self, message: str = "重复发布"):
        super().__init__(40003, message)

class ServerError(APIError):
    def __init__(self, message: str = "服务器未知错误"):
        super().__init__(50000, message)

class InvalidMethodError(APIError):
    def __init__(self, message: str = "无效请求方法"):
        super().__init__(50001, message)

class InvalidParamsError(APIError):
    def __init__(self, message: str = "无效请求参数"):
        super().__init__(50002, message)

class InvalidValueError(APIError):
    def __init__(self, message: str = "无效值"):
        super().__init__(50003, message)

class SignUpLimitError(APIError):
    def __init__(self, message: str = "报名人数达到限制"):
        super().__init__(50007, message)

class WechatServiceError(APIError):
    def __init__(self, message: str = "微信服务错误"):
        super().__init__(50009, message)

class WechatArticleError(APIError):
    def __init__(self, message: str = "获取微信文章失败"):
        super().__init__(50010, message)

class DuplicateSignUpError(APIError):
    def __init__(self, message: str = "重复报名"):
        super().__init__(50011, message) 